<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
  </style>
</head>
<body>

<!--document.createElement('h1')-->
<!--
v-if : 是“真正”的条件渲染
v-show : 总是会被渲染，基于 CSS 的 display 进行切换。
-->

<div id="app">
  <h1>{{msg}}</h1>
  <div v-show="loginType === 'username'">
    <label>Username</label>
    <input placeholder="Enter your username" key="1">
  </div>
  <div v-show="loginType !== 'username'">
    <label>Email</label>
    <input placeholder="Enter your email address" key="2">
  </div>
  <button @click="toggleLoginType">Toggle login type</button>
</div>
<script src="vue.js"></script>
<script>

  new Vue({
    el: '#app',
    data: {
      msg: 'hello key',
      loginType: 'username'
    },
    methods: {
      toggleLoginType() {
        if (this.loginType === 'username') {
          this.loginType = !'username'
        } else {
          this.loginType = 'username'
        }
      }
    }
  })

</script>
</body>
</html>